package com.wmy.luckywheel.controller;


import com.wmy.luckywheel.entity.Result;
import com.wmy.luckywheel.entity.po.Prize;
import com.wmy.luckywheel.service.PrizeService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Sian37
 * 奖品控制器
 */

@Slf4j
@RestController
@RequestMapping("/prize")
@RequiredArgsConstructor
public class PrizeController {

    private final PrizeService reviewService;

    @GetMapping("list")
    public Result<List<Prize>> query() {
        return Result.success(reviewService.queryListAndStart());
    }

    @GetMapping("all")
    public Result<List<Prize>> queryList() {
        return Result.success(reviewService.queryList());
    }


    @PostMapping
    public Result<?> add(@RequestBody Prize prize) {
        log.info("添加奖品：{}", prize);
        reviewService.add(prize);
        return Result.success();
    }

    @PutMapping
    public Result<?> update(@RequestBody Prize prize) {
        log.info("更新奖品：{}", prize);
        reviewService.update(prize);
        return Result.success();
    }

    @DeleteMapping
    public Result<?> delete(@RequestParam Integer id) {
        log.info("删除奖品：{}", id);
        reviewService.delete(id);
        return Result.success();
    }
}
